package t

import "math"

func MaxArea(height []int) int {
	leng := len(height)
	l := 0
	r := leng - 1
	maxArea := 0
	for l < r {
		area := (r-l) * int(math.Min(float64(height[r]), float64(height[l])))
		if height[l] < height[r] {
			l++
		} else {
			r--
		}
		if maxArea < area {
			maxArea = area
		}

	}
	return maxArea
}